-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add stdext module for swoole-cli and enhance PHP standard library #5842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* add marco * merge upstream
* optimize feature * fix error * add mbstring
* optimize feature * Update swoole_stdext.cc --------- Co-authored-by: Tianfeng.Han <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new stdext module for swoole-cli that enhances the PHP standard library by adding support for typed arrays and enabling built-in method calls directly on arrays, strings, and streams. The module allows users to define strongly-typed arrays using syntax like typed_array('<int>')
and call methods like $string->length()
instead of using traditional functions like strlen($string)
.
- Adds typed array functionality with runtime type checking for keys and values
- Implements method call syntax for arrays, strings, and stream resources
- Adds comprehensive test coverage for all new functionality
Reviewed Changes
Copilot reviewed 52 out of 52 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
thirdparty/php/zend/zend_execute.c |
Adds Zend VM execution helper functions for array operations |
thirdparty/php/standard/var_decoder.cc |
Adds support for non-backed enum JSON error handling |
ext-src/swoole_stdext.cc |
Main implementation of the stdext module with typed arrays and method calling |
ext-src/php_swoole_stdext.h |
Header file defining function prototypes for stdext functionality |
ext-src/stubs/php_swoole_stdext.stub.php |
PHP stub definitions for IDE support |
Multiple test files | Comprehensive test coverage for typed arrays, string methods, and array methods |
Build configuration files | Updates to enable stdext compilation option |
SW_EXTERN_C_BEGIN | ||
#include "ext/pcre/php_pcre.h" | ||
#include "ext/json/php_json.h" | ||
#include "thirdparty/php/zend/zend_execute.c" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including a .c file directly is unusual and can lead to multiple definition errors. Consider moving the required code to a header file or linking it properly during compilation.
#include "thirdparty/php/zend/zend_execute.c" | |
#include "thirdparty/php/zend/zend_execute.h" |
Copilot uses AI. Check for mistakes.
} | ||
|
||
zval count = {}; | ||
php_pcre_pce_incref(pce); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version-specific conditional compilation blocks should be documented to explain what functionality differs between versions and why the version check is necessary.
php_pcre_pce_incref(pce); | |
php_pcre_pce_incref(pce); | |
/* | |
* PHP 8.4.0 and later changed the signature of php_pcre_match_impl: | |
* - The 'is_global' argument is now a boolean (global == 1), and the 'use_flags' argument was removed. | |
* - For earlier versions, both 'global' and 'use_flags' (ZEND_NUM_ARGS() >= 3) must be passed. | |
* This conditional ensures compatibility with both versions. | |
*/ |
Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5842 +/- ##
=========================================
Coverage ? 86.18%
=========================================
Files ? 109
Lines ? 16820
Branches ? 2975
=========================================
Hits ? 14497
Misses ? 2323
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1. Add support for type arrays
List
Map
2. Allow built-in methods for array/string/stream (resource)
String
Array
Stream